<template>
    <div>
      <!-- <img src="../assets/logo.png" class="logo"></img> -->
        <el-container>
          <el-header>
            <el-row>
              <el-col :span="4"></el-col>
              <el-col :span="16">后台管理系统</el-col>
              <el-col :span="4"><button class="out" @click="out">退出</button></el-col>
            </el-row>
          </el-header>
          <el-container>
              <el-aside :width="isCollapse ? '60px' : '200px'">
                <div class="zk" @click="isCollapse = !isCollapse">|||</div>
                <el-menu
                  :default-active="$route.path"
                  class="el-menu-vertical-demo"
                  background-color="#545c64"
                  text-color="#fff"
                  :unique-opened="true"
                  :collapse="isCollapse"
                  :collapse-transition="false"
                  router>
                  <el-submenu :index="item.id+''" v-for="item in menuslist" :key="item.id">
                    <template slot="title">
                      <i class="el-icon-location"></i>
                      <span>{{item.authName}}</span>
                    </template>
                    <el-menu-item :index="'/'+it.path" v-for="it in item.children" :key="it.id">
                      <i class="el-icon-setting"></i>
                      <span slot="title">{{it.authName}}</span>
                    </el-menu-item>
                  </el-submenu>
                </el-menu>
              </el-aside>
              <el-main>
                <router-view></router-view>
              </el-main>
          </el-container>
        </el-container>
    </div>
</template>

<script>
import {getmenusApi} from  '../../http/api'
export default {
  name:'home',
  data() {
    return {
      // 侧边栏的展开和收缩
      isCollapse:false,

      menuslist:[],
    }
  },
  created(){
    // 左侧数据
    this.getMenusList()
  },
  methods:{
    async getMenusList(){
      const res = await getmenusApi()
      this.menuslist = res
      console.log(res);
    },
    // 退出
    out(){
      sessionStorage.removeItem('token'),
      this.$router.push('/')
    }
  }
}
</script>

<style>
  .el-container{
    height: 100vh;
  }
 .el-header, .el-footer {
    background-color: #020405;
    color: #fff;
    text-align: center;
    line-height: 60px;
  }
  
  .el-aside {
    background-color: rgb(67, 74, 80);
    color: #fff;
    /* text-align: center; */
    overflow: hidden;
  }
  
  .el-main {
    background-color: #E9EEF3;
    color: #333;
    /* text-align: center;
    line-height: 160px; */
  }
  .el-menu{
    border: none;
  }
  
  body > .el-container {
    margin-bottom: 40px;
  }
  
  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }
  
  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }
  .out{
    border: none;
    background-color: #0b2136;
    color: #fff;
  }
  .zk{
    width: 100%;
    text-align: center;
    line-height: 30px;
    background-color: #262626;
  }
  .logo{
    width: 40px;
    padding-top: 10px;
  }
</style>